package com.snacksmall.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.snacksmall.dto.GoodsCategoryDto;
import com.snacksmall.model.GoodsCategory;
import com.snacksmall.service.IGoodsCategoryService;
@Controller
@ResponseBody
@RequestMapping("/goodsCategory")
public class GoodsCategoryController {
	@Resource
	private IGoodsCategoryService goodsCategoryService;
	@RequestMapping("/queryGoodsCategoryAll.do")
	public Map queryGoodsCategoryAll(GoodsCategoryDto goodsCategoryDto) {
		List<GoodsCategory> list = goodsCategoryService.queryGoodsCategoryAll(goodsCategoryDto);
	    int num = goodsCategoryService.countSum(goodsCategoryDto);
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("code",0);
		map.put("msg","");
	    map.put("count",num);
	    map.put("data",list);
		return map;
		
	}
	@RequestMapping("/addGoodsCategory.do")
	public int addGoodsCategoryl(GoodsCategory goodsCategory) {
		
		return goodsCategoryService.addGoodsCategory(goodsCategory);
		
	}
	@RequestMapping("/editGoodsCategory.do")
	public int editGoodsCategoryl(GoodsCategory goodsCategory) {
		return goodsCategoryService.editGoodsCategory(goodsCategory);
		
	}
	@RequestMapping("/delGoodsCategory.do")
	public int delGoodsCategory(int categoryId) {
		return goodsCategoryService.delGoodsCategory(categoryId);
		
	}
}
